import codecs
class DataOutput:
    def __init__(self):
        self.datas = []

    def store_data(self,data):
        if data is None:
            return
        self.datas.append(data)

    def output_html(self):
        with codecs.open('baike.html','w',encoding='utf_8') as f:
            f.write('<html>')
            f.write('<head><meta charset="UTF-8"></head>')
            f.write('<body>')
            f.write('<table>')
            for data in self.datas:
                f.write('<tr>')
                f.write('<td>%s</td>'%data['url'])
                f.write('<td>%s</td>'%data['title'])
                f.write('<td>%s</td>' % data['summary'])
                f.write('</tr>')
                self.datas.remove(data)
            f.write('</table>')
            f.write('</body>')
            f.write('</html>')
            f.close()
